//
//  UIView+SplitLine.m
//  开店通
//
//  Created by 张浩 on 15/7/8.
//  Copyright (c) 2015年 张浩. All rights reserved.
//

#import "UIView+SplitLine.h"

@implementation UIView (SplitLine)
+ (UIView *)line
{
    UIView *splitLine = UIView.new;
    splitLine.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
    return splitLine;
}

- (void)addTopSplitLine
{
    UIView * line = [UIView line];
    [self addSubview:line];
    [line makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(0);
        make.height.equalTo(0.5);
    }];
}

- (void)addBottomSplitLine
{
    UIView * line = [UIView line];
    [self addSubview:line];
    [line makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(0);
        make.height.equalTo(0.5);
    }];
}

- (void)addSplitLineAtBottomWith:(UIView *)view
{
    UIView * line = [UIView line];
    [self addSubview:line];
    [line makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(view.bottom);
        make.height.equalTo(0.5);
    }];
}

+ (UIView *)contentViewWithSplitLine
{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    [view addTopSplitLine];
    
    [view addBottomSplitLine];
    return view;
}

- (void)addSplitLineWithFrame:(CGRect)frame;
{
    UIView *splitLine = [UIView line];
    [self addSubview:splitLine];
    
    splitLine.frame = frame;
}
@end
